package com.cat.model.biz.logic.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alonew.db.dao.TxCommonDAO;
import com.cat.model.biz.logic.BasLogic;
import com.cat.model.common.model.common.BasConfigVO;
import com.cat.model.dao.common.PlmCommDAO;

@Service("basLogic")
public class BasLogicImpl implements BasLogic {

	@Autowired
	private TxCommonDAO commonDAO;
	
	@Autowired
	private PlmCommDAO plmCommDAO;
	
	@SuppressWarnings("unchecked")
	@Override
	public List<BasConfigVO> getBasConfigByName(String name) {
		Map<String, Object> condition = new HashMap<String, Object>();
		condition.put("name", name);
		return  (List<BasConfigVO>)plmCommDAO.query("manager.getBasConfig", condition);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public BasConfigVO getOneConfigByName(String name) {
		Map<String, Object> condition = new HashMap<String, Object>();
		condition.put("name", name);
		List<BasConfigVO> configList = (List<BasConfigVO>)plmCommDAO.query("manager.getBasConfig", condition);
		if(configList != null && configList.size() > 0){
			return configList.get(0);
		}
		return null;
	}
	
}
